/*! \file SimpleConfig.cpp
 *	\brief 
 *
 *	created:	2009/11/24
 *	created:	24:11:2009   13:52
 *	filename: 	o:\gag-engine\libs\config\SimpleConfig.cpp
 *	file path:	o:\gag-engine\libs\config
 *	file base:	SimpleConfig
 *	file ext:	cpp
 *	author:		Vitalii Trubchaninov
 *				venngraydog@gmail.com
 */

#include "StdAfx.h"
#include "SimpleConfig.h"

namespace tt{
namespace config{

SimpleConfig::SimpleConfig(void)
: m_ints()
, m_strings()
, m_bools()
{
}

SimpleConfig::~SimpleConfig(void)
{
}

void SimpleConfig::onSetInt( const String& key, Int value )
{
	m_ints[key] = value;
}

void SimpleConfig::onSetUInt( const String& key, UInt value )
{
	setInt( key, UInt(value) );
}

Int SimpleConfig::onGetInt( const String& key, Int default_value/* = 0*/ )
{
	Ints::const_iterator it = m_ints.find(key);
	if (it != m_ints.end())
		return (DWORD)it->second;

	return default_value;
}

UInt SimpleConfig::onGetUInt( const String& key, UInt default_value/* = 0*/ )
{
	return UInt( getInt(key, default_value) );
}

void SimpleConfig::onSetString( const String& key, const String& value )
{
	m_strings[key] = value;
}

String SimpleConfig::onGetString( const String& key )
{
	Strings::const_iterator it = m_strings.find(key);
	if (it != m_strings.end())
		return it->second;

	return String();
}

const String& SimpleConfig::onGetString( const String& key, const String& default_value )
{
	Strings::const_iterator it = m_strings.find(key);
	if (it != m_strings.end())
		return it->second;

	return default_value;
}

void SimpleConfig::onSetBool( const String& key, bool value )
{
	m_bools[key] = value;
}

bool SimpleConfig::onGetBool( const String& key, bool default_value/* = false*/ )
{
	Bools::const_iterator it = m_bools.find(key);
	if (it != m_bools.end())
		return it->second;

	return default_value;
}

} //namespace config
} //namespace tt

